import request from "@/utils/request";

function page(current, size) {
    return request({
        method: 'GET',
        url: '/training_program/page',
        params: {
            current: current,
            size: size
        }
    });
}

function add(grade, majorId) {
    return request({
        method: 'POST',
        url: '/training_program',
        data: {
            grade: grade,
            majorId: majorId,
        }
    });
}

function edit(id, grade, majorId) {
    return request({
        method: 'PUT',
        url: '/training_program',
        data: {
            id: id,
            grade: grade,
            majorId: majorId,
        }
    });
}

function del(id) {
    return request({
        method: 'DELETE',
        url: `/training_program/${id}`,
    });
}

function course_page(trainingProgramId, current, size, category,
    semesterId, selectionMethod, assessmentMethod
) {
    return request({
        method: 'GET',
        url: '/training_program_course/page_by_training_program_id',
        params: {
            trainingProgramId: trainingProgramId,
            current: current,
            size: size,
            category: category,
            semesterId: semesterId,
            selectionMethod: selectionMethod,
            assessmentMethod: assessmentMethod
        }
    });
}

function course_add(trainingProgramId, courseId) {
    return request({
        method: 'POST',
        url: '/training_program_course',
        data: {
            trainingProgramId: trainingProgramId,
            courseId: courseId,
        }
    });
}

function course_edit(id, trainingProgramId, courseId) {
    return request({
        method: 'PUT',
        url: '/training_program_course',
        data: {
            id: id,
            trainingProgramId: trainingProgramId,
            courseId: courseId,
        }
    });
}

function course_del(trainingProgramId, courseId) {
    return request({
        method: 'DELETE',
        url: `/training_program_course`,
        data: {
            trainingProgramId: trainingProgramId,
            courseId: courseId
        }
    });
}

export default {
    page,
    course_page,
    add,
    edit,
    del,
    course_add,
    course_edit,
    course_del,
}